#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main(int argc, int *argv[])
{
    int fd;
    char buf[32];
    fd = open(argv[1], O_RDWR);
    if (fd < 0)
    {
        perror("打开失败\n");
        return -1;
    }
    if (strcmp(argv[2],"A")==0)
        write(fd,"A",10);
    else if(strcmp(argv[2],"B")==0)
        write(fd,"B",10);
    close(fd);
    return 0;
}